<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        
        // 同步代码执行完毕再执行Promise里的结果
        console.log(1);

        function createPromiseObj() {
            console.log(2);
            // new Promise()被实例化后，函数体里的代码立即执行
            return new Promise((resolve, reject) => { 
                console.log(3);
                resolve('成功')
                console.log(4);
            })
            console.log(5);
        }
        console.log(6);
        test()
        console.log(7);
        async function test() {
            console.log(8);
            const re = await createPromiseObj()  
            console.log(re);
            console.log(9);
        }
        console.log(10);

        //  1 6 8 2 3 4 7 10 成功 9  
    </script>
</body>

</html>